package com.springboot.service.impl;

import com.springboot.dao.StudentDao;
import com.springboot.domain.Student;
import com.springboot.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;

@Service
public class StudentServiceImpl implements StudentService {

    @Autowired
    private StudentDao studentDao;

    @Override
    public Student getById(Integer id) {
        Student student = studentDao.selectByPrimaryKey(id);
        return student;
    }

    @Override
    public List<Student> getAll() {
        List<Student> list = studentDao.getAll();
        return list;
    }

    @Override
    public Integer save(Student student) {
        Integer count = studentDao.insert(student);
        return count;
    }

    @Override
    public Integer edit(Student student) {
        Integer count = studentDao.updateByPrimaryKey(student);
        return count;
    }

    @Override
    public Integer delete(Integer id) {
        Integer count = studentDao.deleteByPrimaryKey(id);
        return count;
    }
}
